package com.yj.web.service.impl;

import backMsg.BackMsgSender;
import com.yj.web.dao.mapper.AdminUserMapper;
import com.yj.web.dao.mapper.FundraisingProjectMapper;
import com.yj.web.dao.po.InterestVO2;
import com.yj.web.dao.po.admin.*;
import com.yj.web.help.IdGenerater;
import com.yj.web.help.JsonMapper;
import com.yj.web.service.FundraisingProjectService;
import com.yj.web.service.MessageService;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.math.BigDecimal;
import java.time.LocalDate;
import java.time.LocalDateTime;
import java.time.LocalTime;
import java.util.ArrayList;
import java.util.HashSet;
import java.util.List;
import java.util.Set;

/**
 * Created by yanlinyang on 2017/7/4.
 */
@Service("fundraisingProjectService")
public class FundraisingProjectServiceImpl implements FundraisingProjectService {
    private static final Logger logger = LoggerFactory.getLogger(FundraisingProjectServiceImpl.class);


    private static final String PREFIX_PIC = "http://api.yinuochoukuan.com/public/previewImg?id=";

    @Autowired
    private FundraisingProjectMapper fundraisingProjectMapper;
    @Autowired
    private AdminUserMapper adminUserMapper;

    @Autowired
    private InterestService interestService;

    @Autowired
    private MessageService messageService;

    /**
     *
     * @param statuses
     * @param borrower_name
     * @param borrower_phone
     * @param startTime
     * @param endTime
     * @param page
     * @param size
     * @return
     * @throws Exception
     */
    @Override
    public List<FundraisingProject> listFundraisingProject (List<Integer> statuses, String borrower_name, String borrower_phone, String startTime, String endTime, int page, int size) throws Exception {
        List<FundraisingProject> projects = null;
//        List<FundraisingProject> projects2 = null;

        LocalDate date = LocalDate.now();
        LocalDateTime dateTimeStart = date.atTime(0,0,0);
        LocalDateTime dateTimeEnd = date.atTime(23,59,59);
        Set<String> repayProjectIds = fundraisingProjectMapper.repayTodayUnpaid(dateTimeStart.toString().replace("T", " "), dateTimeEnd.toString().replace("T", " "));

//        Set<String> ids = new HashSet<>();
        int offset = (page - 1) * size;
        projects = fundraisingProjectMapper.listFundraisingProject(statuses, borrower_name, startTime, endTime, borrower_phone, offset, size);
//        for (FundraisingProject project : projects1) {
//            ids.add(project.getBorrower_id());
//        }
//        if (0 == ids.size()) {
//            return null;
//        }
//        projects2 = fundraisingProjectMapper.listFundraisingProjectByBorrPhone(borrower_phone, ids, offset, size);
//
//        for (FundraisingProject project2 : projects2) {
//            for (FundraisingProject project1 : projects1) {
//                if (project1.getBorrower_id().equals(project2.getBorrower_id()) && (project1.getId().equals(project2.getId()))) {
//                    PoUtil.supplementPo(project1, project2);
//                    if (repayProjectIds.contains(project2.getId())) {
//                        project2.setStatus(16);//今日还款(未还款)
//                    } else if (repayedProjectIds.contains(project2.getId())) {
//                        project2.setStatus(17);//今日还款(已还款)
//                    }
//                }
//            }
//        }
        Set<String> projectIdsPayedUnsplit = fundraisingProjectMapper.findRepayPlanPayedUnsplit();
        if (null != projects && projects.size() > 0) {
            for (FundraisingProject project : projects) {
                if (repayProjectIds.contains(project.getId())) {
                    project.setStatus(16);//今日还款(未还款)
                }
                if (projectIdsPayedUnsplit.contains(project.getId())) {
                    project.setStatus(17);
                }
            }
        }



        return projects;
    }

    @Override
    public int countFundraisingProject(List<Integer> statuses, String borrower_name, String borrower_phone, String startTime, String endTime) {
        List<FundraisingProject> projects1 = new ArrayList<>();
//        projects1 =fundraisingProjectMapper.listFundraisingProjectByBorrNameCreaTime(statuses, borrower_name, startTime, endTime);
//        Set<String> ids = new HashSet<>();
//        for (FundraisingProject project : projects1) {
//            ids.add(project.getBorrower_id());
//        }
        int count = fundraisingProjectMapper.countFundraisingProject(statuses, borrower_name, startTime, endTime, borrower_phone);
        return count;
    }

    @Override
    public FundraisingProject findFundraisingProjectById(String id) {
        FundraisingProject project = fundraisingProjectMapper.findFundraisingProjectById(id);
        List<CheckSuggestion> suggestions = fundraisingProjectMapper.findCheckSuggestionByProjectId(id);
        project.setCheck_suggestions(suggestions);
        String phone = fundraisingProjectMapper.findPhoneById(project.getBorrower_id());
        project.setBorrower_phone(phone);

        //借款人图片
        String bicri = project.getBorrower_id_card_resource_ids();
        List<Picture> pictures = null;
        if (null != bicri) {
            pictures = parsePictures(bicri);
            if (null != pictures && pictures.size() > 0) {
                for (Picture picture : pictures) {
                    if (picture.getId() != null) {
                        picture.setUrl(PREFIX_PIC + picture.getId());
                    }
                }
            }
            project.setBicPictures(pictures);
        }

        //项目图片
        String resource_ids = project.getResource_ids();
        if (null != resource_ids) {
            pictures = parsePictures(resource_ids);
            if (null != pictures && pictures.size() > 0) {
                for (Picture picture : pictures) {
                    if (picture.getId() != null) {
                        picture.setUrl(PREFIX_PIC + picture.getId());
                    }
                }
            }
            project.setResourcePictures(pictures);
        }

        LocalDate date = LocalDate.now();
        LocalDateTime dateTimeStart = date.atTime(0,0,0);
        LocalDateTime dateTimeEnd = date.atTime(23,59,59);
        Set<String> repayProjectIds = fundraisingProjectMapper.repayTodayUnpaid(dateTimeStart.toString().replace("T", " "), dateTimeEnd.toString().replace("T", " "));
        if (repayProjectIds.contains(project.getId())) {
            project.setStatus(16);//今日还款(未还款)
        }

        Set<String> projectIdsPayedUnsplit = fundraisingProjectMapper.findRepayPlanPayedUnsplit();
        if (projectIdsPayedUnsplit.contains(project.getId())) {
            project.setStatus(17);//已还款未分账
        }
        return project;
    }

    private List<Picture> parsePictures(String jsonPics) {
        List<Picture> pictures = new ArrayList<>();
        JsonMapper jsonMapper = new JsonMapper();
        jsonPics = jsonPics.substring(1,jsonPics.length()-1);
        String[] ss = jsonPics.split("},");
        for (String s : ss) {
            if (!s.endsWith("}")) {
                s = s + "}";
            }
            Picture picture = jsonMapper.fromJson(s, Picture.class);
            String picPath = fundraisingProjectMapper.findPicPath(picture.getId());
            picture.setPath(picPath);
            pictures.add(picture);
        }
        return pictures;
    }

    @Override
    public List<InvestRecord> findInvestRecordByProjectId(String projectId, int page, int size) {
        int offset = (page - 1) * size;
        List<InvestRecord> investRecords = fundraisingProjectMapper.findInvestRecordByProjectId(projectId, offset, size);
        return investRecords;
    }

    @Override
    public List<RepayPlan> findRepayPlanByProjectId(String projectId, int page, int size) {
        int offset = (page - 1) * size;
        FundraisingProject project = fundraisingProjectMapper.findFundraisingProjectById(projectId);
        if (!((project.getStatus()==11)||(project.getStatus()==13)||(project.getStatus()==15))) {
            return null;
        }
        List<RepayPlan> repayPlen = fundraisingProjectMapper.findRepayPlanByProjectId(projectId, offset, size);
        if (null != repayPlen && repayPlen.size() > 0) {
            for (RepayPlan repayPlan : repayPlen) {
                if (repayPlan.getCurrent_period() < project.getPeriods()) {
                    double remainAmount = fundraisingProjectMapper.calculateRepayPlanRemainAmount(projectId, repayPlan.getCurrent_period());
                    repayPlan.setRemain_amount(remainAmount);
                } else {
                    repayPlan.setRemain_amount(0);
                }

//                LocalDate date = LocalDate.now();
//                String plan_repay_at = repayPlan.getPlan_repay_at();
//                int i = plan_repay_at.indexOf(" ");
//                plan_repay_at = plan_repay_at.substring(0, i);
//                LocalDate planDate = LocalDate.parse(plan_repay_at);
//                if (date.isAfter(planDate)) {
//                    repayPlan.setStatus(3);//1：未还款，2：已还款, 3:
//                }
            }
        }
        return repayPlen;
    }

    //终止项目，只进行数据库操作，没有返回结果，无需转换单位

    /**
     * 更新cus_project_fundraising_detail表
     * @param id
     * @return
     */
    @Override
    @Transactional
    public boolean terminateProject(String id) {
        FundraisingProject project = fundraisingProjectMapper.findFundraisingProjectById(id);//元

        ProjectTip tip = new ProjectTip();
        tip.setUser_id(project.getBorrower_id());
        tip.setTitle(project.getTitle() + "项目放弃筹款");
        tip.setMsg_body(project.getBorrower_name() + "您已放弃项目" + project.getTitle()+ "的筹款，筹款金额将退还至出借用户。");
        tip.setFund_project_id(id);
        tip.setProject_type(0);
        tip.setMsg_type(1);
        String tipId = IdGenerater.generateId("11");
        tip.setId(tipId);
        fundraisingProjectMapper.insertProjectTip(tip);//发起人

        if (3 == project.getStatus()) {
            List<InvestRecord> investRecords = fundraisingProjectMapper.findInvestRecordByProjectIdNoPaging(id);//以分为单位
            if (null != investRecords && 0 != investRecords.size()) {
                for (InvestRecord investRecord : investRecords) {
                    CapitalChange capitalChange = new CapitalChange();
                    capitalChange.setChange_type(1);
                    capitalChange.setBl_sign(1);
                    capitalChange.setChangeAmount(investRecord.getInvestment());
                    Double balanceAmt = adminUserMapper.findBalanceAmt(investRecord.getLenderId())+investRecord.getInvestment();//分账后的账户余额，以分为单位
                    capitalChange.setBalanceAmount(balanceAmt);
                    String account_id = adminUserMapper.getAccountIdById(investRecord.getLenderId());
                    capitalChange.setAccount_id(account_id);
                    //生成CapitalChange的id
                    String capitalChangeId = IdGenerater.generateId("11");
                    capitalChange.setChangeId(capitalChangeId);
                    adminUserMapper.insertCapitalChange(capitalChange);//更新账户明细表cus_account_detail
                    adminUserMapper.updateAccountBalanceAmt(investRecord.getLenderId(), balanceAmt);//更新账户表cus_account

                    tip.setUser_id(investRecord.getLenderId());
                    tip.setTitle(project.getTitle() + "项目终止筹款");
                    tip.setMsg_body("借款用户已放弃您支持的项目 " + project.getTitle()+ " ，您支持的金额将会原路返还到您的账户。");
                    tip.setFund_project_id(id);
                    tip.setProject_type(1);
                    tip.setMsg_type(1);
                    tipId = IdGenerater.generateId("11");
                    tip.setId(tipId);
                    fundraisingProjectMapper.insertProjectTip(tip);//支持者
                }
            }
        }
        fundraisingProjectMapper.updateProjectFundraisingDetailTerminateProject(id);
        return fundraisingProjectMapper.terminateProject(id);
    }

    /**
     * 更新cus_project_repay_plan，cus_project_return_plan
     * 只操作数据库，不返回结果，无需修改单位
     * @param id 项目id
     * @return
     */
    @Override
    @Transactional
    public boolean confirmLoan(String id) {
        FundraisingProject project = fundraisingProjectMapper.findFundraisingProjectById(id);//元
        if (null == project) {
            return false;
        }
        int cur_amount = fundraisingProjectMapper.findProjectCur_amountById(id);//以分为单位
        int periods = project.getPeriods();
        LocalDate date = LocalDate.now();
        date = date.minusDays(1);
        LocalDateTime dateTime = date.atTime(0, 0, 0);
        String plan_repay_at = null;

//        if (0 != (project.getAmount() - cur_amount)) {
            long total_interest = 0;
            float annual_rate = project.getAnnual_rate();
            for (int i = 0; i < periods; i++) {
                InterestVO2 interestVO2 = interestService.calcEqPrincipalAndInterest(cur_amount, annual_rate, periods, i+1, BigDecimal.ROUND_HALF_EVEN);//以分为单位
                LocalDateTime dateTime1 = dateTime.plusMonths(i+1);
                plan_repay_at = dateTime1.toString().replace("T", " ");

                total_interest += interestVO2.getInterest();//计算筹款项目表的应付总利息total_interest, 以分为单位

                RepayPlan repayPlan = fundraisingProjectMapper.findRepayPlanByProjIdPeriod(id, i+1);
                repayPlan.setPrincipal_amount(interestVO2.getPrincipal());//以分为单位
                repayPlan.setInterest_amount(interestVO2.getInterest());//以分为单位
                repayPlan.setPlan_repay_at(plan_repay_at);
                fundraisingProjectMapper.updateRepayPlan(repayPlan);//更新还款计划,以分为单位

//                int investRecordCount = fundraisingProjectMapper.countInvestRecordByProjectId(id);
                List<InvestRecord> investRecords = fundraisingProjectMapper.findInvestRecordByProjectIdNoPaging(id);//以分为单位
                for (InvestRecord investRecord : investRecords) {
                    //* --> 单项，
                    ReturnPlan returnPlan = fundraisingProjectMapper.findReturnPlanByProjectIdPeriodUserid(id, i+1, investRecord.getLenderId(), investRecord.getInvestId());//以分为单位
                    interestVO2 = interestService.calcEqPrincipalAndInterest(Math.round(investRecord.getInvestment()), annual_rate, periods, i+1, BigDecimal.ROUND_DOWN);//以分为单位
                    returnPlan.setPrincipal_amount(interestVO2.getPrincipal());
                    returnPlan.setInterest_amount(interestVO2.getInterest());
                    returnPlan.setPlan_return_at(plan_repay_at);
                    fundraisingProjectMapper.updateReturnPlan(returnPlan);//更新回款计划
                }
            }
        //增加一条账户明细的记录，并更新账户的账户余额
        CapitalChange capitalChange = new CapitalChange();
        capitalChange.setChange_type(9);//确认放款转账
        capitalChange.setBl_sign(1);
        capitalChange.setChangeAmount((double)cur_amount);//分
        Double balanceAmt = adminUserMapper.findBalanceAmt(project.getBorrower_id())+cur_amount;//账户余额
        capitalChange.setBalanceAmount(balanceAmt);
        String account_id = adminUserMapper.getAccountIdById(project.getBorrower_id());
        capitalChange.setAccount_id(account_id);
        //生成CapitalChange的id
        String capitalChangeId = IdGenerater.generateId("11");
        capitalChange.setChangeId(capitalChangeId);
        adminUserMapper.insertCapitalChange(capitalChange);
        adminUserMapper.updateAccountBalanceAmt(project.getBorrower_id(), balanceAmt);
//        }
        fundraisingProjectMapper.updateProjectFundraisingDetailStatusConfirmLoan(id);
        return fundraisingProjectMapper.confirmLoan(id, total_interest, plan_repay_at);
    }

    //还款分账，cus_project_fundraising_detail，cus_account_detail，cus_account, cus_project_return_plan，cus_project_repay_plan
    /**
     *只是操作数据库，不返回任何结果，所以不用进行单位转换
     * @param id projectId
     * @param period 表示第几期还款
     * @return
     */
    @Override
    @Transactional
    public boolean splitByAccount(String id, int period) {
        RepayPlan repayPlan = fundraisingProjectMapper.findRepayPlanByProjIdPeriod(id, period);//以分为单位
        if (2 != repayPlan.getStatus() || 0 != repayPlan.getSplit_status()) {//已还款未分账
            return false;
        }
        FundraisingProject project = fundraisingProjectMapper.findFundraisingProjectById(id);
        List<ReturnPlan> returnPlen = fundraisingProjectMapper.findReturnPlanByProjectIdPeriod(id, period);//以分为单位
        if (null != returnPlen && returnPlen.size() > 0) {
            for (ReturnPlan returnPlan : returnPlen) {
                returnPlan.setStatus(2);//状态（1：未还款，2：已还款）
                LocalDateTime dateTime = LocalDateTime.now();
                String real_return_at = dateTime.toString().replace("T", " ");
                returnPlan.setReal_return_at(real_return_at);
                //cus_project_return_plan
                fundraisingProjectMapper.updateReturnPlan(returnPlan);
                int sumRepaymentAmount = fundraisingProjectMapper.sumRepaymentAmount(id, returnPlan.getLender_user_id(), returnPlan.getProject_fund_detail_id());//已还本金
                int sumRepaymentProfitAmount = fundraisingProjectMapper.sumRepaymentProfitAmount(id, returnPlan.getLender_user_id(), returnPlan.getProject_fund_detail_id());//已还利息
                //cus_project_fundraising_detail
                fundraisingProjectMapper.updateProjectFundraisingDetail(id, returnPlan.getLender_user_id(), returnPlan.getProject_fund_detail_id(), sumRepaymentAmount, sumRepaymentProfitAmount);

                CapitalChange capitalChange = new CapitalChange();
                capitalChange.setChange_type(10);
                capitalChange.setBl_sign(1);
                double changeAmount = returnPlan.getPrincipal_amount()+returnPlan.getInterest_amount();//以分为单位
                capitalChange.setChangeAmount(changeAmount);
                Double balanceAmt = adminUserMapper.findBalanceAmt(returnPlan.getLender_user_id())+changeAmount;//分账后的账户余额，以分为单位
                capitalChange.setBalanceAmount(balanceAmt);
                String account_id = adminUserMapper.getAccountIdById(returnPlan.getLender_user_id());
                capitalChange.setAccount_id(account_id);
                //生成CapitalChange的id
                String capitalChangeId = IdGenerater.generateId("11");
                capitalChange.setChangeId(capitalChangeId);
                adminUserMapper.insertCapitalChange(capitalChange);
                adminUserMapper.updateAccountBalanceAmt(returnPlan.getLender_user_id(), balanceAmt);

                ProjectTip tip = new ProjectTip();
                tip.setUser_id(returnPlan.getLender_user_id());
                tip.setTitle(project.getTitle() + "项目回款成功");
                String userphone = adminUserMapper.getUserPhoneById(returnPlan.getLender_user_id());
                String msg = userphone +  "您好，您支持的项目" + project.getTitle() + "，收到第" + period + "期回款，共回款" + changeAmount/100 + "元（含本金" + returnPlan.getPrincipal_amount()/100 + "元，利息" + returnPlan.getInterest_amount()/100 + "元）。";
                tip.setMsg_body(msg);

                tip.setFund_project_id(id);
                tip.setProject_type(1);
                tip.setMsg_type(1);
                String tipId = IdGenerater.generateId("11");
                tip.setId(tipId);
                fundraisingProjectMapper.insertProjectTip(tip);//支持人

                //亿美短信提醒
                String msgContent = "【医诺筹款】"+msg;
                String phone = adminUserMapper.getUserPhoneById(returnPlan.getLender_user_id());
//                String templateCode = "";
//                String templateParam = "{\"name\":\""+ realname +"\", \"title\":\""+ project.getTitle() +"\", \"period\":\""+ period +"\", \"changeAmount\":\""+ changeAmount +"\", \"principal\":\""+ returnPlan.getPrincipal_amount() +"\", \"interest\":\""+ returnPlan.getInterest_amount() +"\"}";
                try {
                    BackMsgSender.sendSingleSms(msgContent, phone);

                    Message message = new Message();
                    message.setReceiverStr(phone);
                    Set<String> receivers = new HashSet<>();
                    receivers.add(phone);
                    message.setReceivers(receivers);
                    message.setNumber(1);
                    message.setContent(msgContent);
                    message.setStatus(1);
                    message.setType(2);
                    messageService.insertMessage(message);
                } catch (Exception e) {
                    e.printStackTrace();
                    throw new RuntimeException(e);
                }
            }
            repayPlan.setSplit_status(1);//是否分账（0否,1是）
            //如果是最后一期，项目结束，更新cus_fundraising_project和cus_project_fundraising_detail
//            int periods = fundraisingProjectMapper.findPeriodByProjectId(id);
            if (period == project.getPeriods()) {
                fundraisingProjectMapper.updateProjectFundraisingDetailStatusFinish(id);
                fundraisingProjectMapper.updateProjectStatusFinish(id);
            }
            //cus_project_repay_plan
            return fundraisingProjectMapper.updateRepayPlan(repayPlan);
        }
        return false;
    }



    @Override
    public int countRepayPlanByProjectId(String projectId) {
        return fundraisingProjectMapper.countRepayPlanByProjectId(projectId);
    }

    @Override
    public int countInvestRecordByProjectId(String projectId) {
        return fundraisingProjectMapper.countInvestRecordByProjectId(projectId);
    }

    @Override
    @Transactional
    public int checkProject(CheckSuggestion suggestion) {
        ProjectTip tip = new ProjectTip();
        FundraisingProject project = fundraisingProjectMapper.findFundraisingProjectById(suggestion.getProject_id());
        if (1 == suggestion.getStatus()) {
            LocalDate start_atDate = LocalDate.now();
            LocalDateTime start_at = start_atDate.atTime(LocalTime.now());
            LocalDateTime end_at = start_atDate.plusDays(project.getFund_total_days()-1).atTime(23,59,59);
            fundraisingProjectMapper.updateFundraisingProjectStatusApprove(suggestion.getProject_id(), start_at.toString().replace("T", " "), end_at.toString().replace("T", " "));//通过审核，更新项目状态为3已通过(筹款中)

            boolean flag = fundraisingProjectMapper.updateUserRealNameAuth(project.getBorrower_id());//实名认证
            if (true == flag) {
                fundraisingProjectMapper.updateCusUserInfo(project.getBorrower_id(), project.getBorrower_name(), project.getBorrower_id_card());
            }

            tip.setUser_id(project.getBorrower_id());
            tip.setTitle(project.getTitle() + "项目申请通过");
            tip.setMsg_body(project.getBorrower_name() + "您好，您的项目 " + project.getTitle()+ " 已提交申请通过，请立即分享给身边的亲朋好友进行筹款吧");
            tip.setFund_project_id(suggestion.getProject_id());
            tip.setProject_type(0);
            tip.setMsg_type(1);
            String id = IdGenerater.generateId("11");
            tip.setId(id);
            fundraisingProjectMapper.insertProjectTip(tip);
        } else {
            fundraisingProjectMapper.updateFundraisingProjectStatusDeny(suggestion.getProject_id());
            tip.setUser_id(project.getBorrower_id());
            tip.setTitle(project.getTitle() + "项目申请失败");
            tip.setMsg_body(project.getBorrower_name() + "您好，您的项目 " + project.getTitle()+ " 审核失败，原因：" + suggestion.getCheck_suggestion() + "请进入“我的-发起的项目”中查看详情。");
            tip.setFund_project_id(suggestion.getProject_id());
            tip.setProject_type(0);
            tip.setMsg_type(1);
            String id = IdGenerater.generateId("11");
            tip.setId(id);
            fundraisingProjectMapper.insertProjectTip(tip);
        }
        fundraisingProjectMapper.updateFundraisingProjectSuggestion(suggestion);
        return fundraisingProjectMapper.insertCheckSuggestion(suggestion);
    }

    @Override
    public boolean hideDisplayProject(String id, int hide_flag) {
        if (0 == hide_flag) {
            return fundraisingProjectMapper.hideProject(id);
        } else {
            return fundraisingProjectMapper.displayProject(id);
        }
    }

    @Override
    public boolean remindRepay(String projectId, String phone) {
        FundraisingProject project = fundraisingProjectMapper.findFundraisingProjectById(projectId);
        RepayPlan repayPlan = fundraisingProjectMapper.findRepayPlanByProjIdPeriod(projectId, 1);

        //亿美短信提醒
        String msgContent = null;
        if (project.getStatus() == 13) {
            msgContent = "【医诺筹款】您的筹款项目\"" + project.getTitle() + "\"已逾 期，本期应还金额" + repayPlan.getRepay_amount() + "元，请登录医诺公众号：医诺在线，及时偿还，若已还清请忽略。";
        } else {
            msgContent = "【医诺筹款】您的筹款项目\"" + project.getTitle() + "\"，本期应还金额" + repayPlan.getRepay_amount() + "元，请登录医诺公众号：医诺在线，及时偿还，若已还清请忽略。";
        }
        BackMsgSender.sendSingleSms(msgContent, phone);
        logger.info("项目还款提醒（当天）{} - {}", phone, msgContent);

        Message message = new Message();
        message.setReceiverStr(phone);
        Set<String> receivers = new HashSet<>();
        receivers.add(phone);
        message.setReceivers(receivers);
        message.setNumber(1);
        message.setContent(msgContent);
        message.setStatus(1);
        message.setType(2);
        messageService.insertMessage(message);
        return true;
    }
//    public boolean displayProject(String id) {
//        return fundraisingProjectMapper.displayProject(id);
//    }
}
